import Mock from 'mockjs'
export default {
  getMenu: (config) => {
    const { username, password } = JSON.parse(config.body)
    //判断用户是否存在  账号密码是否正确
    if (username === 'admin' && password === 'admin') {
      return {
        code: 200,
        data: {
          userInfo: {
            role: '超级管理员', //角色
            avatar: 'admin.png', //头像
          },
          menu: [
            {
              path: '/home',
              name: 'home',
              label: '首页',
              icon: 's-home',
              url: 'home/index.vue',
            },

            {
              label: '用户管理',
              icon: 'user',
              children: [
                {
                  path: '/user',
                  name: 'user',
                  label: '用户列表',
                  icon: 's-grid',
                  url: 'users/index.vue',
                },
              ],
            },
            {
              label: '商品管理',
              icon: 'shopping-bag-2',
              children: [
                {
                  path: '/list',
                  name: 'goods',
                  label: '商品列表',
                  icon: 's-grid',
                  url: 'goods/goodsList.vue',
                },

                {
                  path: '/category',
                  name: 'cate',
                  label: '分类管理',
                  icon: 's-grid',
                  url: 'goods/cate.vue',
                },
              ],
            },
            //订单管理
            {
              label: '订单管理',
              icon: 's-order',
              children: [
                {
                  path: '/order',
                  name: 'order',
                  label: '订单列表',
                  icon: 's-grid',
                  url: 'order/index.vue',
                },
              ],
            },

            //数据统计
            {
              label: '数据统计',
              icon: 's-data',
              children: [
                {
                  path: '/report',
                  name: 'report',
                  label: '数据报表',
                  icon: 's-grid',
                  url: 'report/index.vue',
                },
              ],
            },
          ],
          token: Mock.Random.guid(),
          message: '管理员菜单栏获取成功！',
        },
      }
    } else if (username === 'user' && password === 'user') {
      return {
        code: 200,
        data: {
          userInfo: {
            role: '普通用户',
            avatar: 'user.jpg',
          },
          menu: [
            {
              path: '/home',
              name: 'home',
              label: '首页',
              icon: 's-home',
              url: 'home/index.vue',
            },
            {
              label: '商品管理',
              icon: 'shopping-bag-2',
              children: [
                {
                  path: '/list',
                  name: 'goods',
                  label: '商品列表',
                  icon: 's-grid',
                  url: 'goods/goodsList.vue',
                },
                {
                  path: '/category',
                  name: 'cate',
                  label: '分类管理',
                  icon: 's-grid',
                  url: 'goods/cate.vue',
                },
              ],
            },

            //订单管理
            {
              label: '订单管理',
              icon: 's-order',
              children: [
                {
                  path: '/order',
                  name: 'order',
                  label: '订单管理',
                  icon: 's-grid',
                  url: 'order/index.vue',
                },
              ],
            },
            //数据统计
            {
              label: '数据统计',
              icon: 's-data',
              children: [
                {
                  path: '/report',
                  name: 'report',
                  label: '数据报表',
                  icon: 's-grid',
                  url: 'report/index.vue',
                },
              ],
            },
          ],
          token: Mock.Random.guid(),
          message: '用户菜单栏获取成功！',
        },
      }
    } else {
      return {
        code: 404,
        data: {
          message: '账号或密码错误！',
        },
      }
    }
  },
}
